-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepend crate name to functions with nr2 #3265
Conversation
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Prepend crate name to function's ir name. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove passing tests from exclude list. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
I'm pretty sure this is an issue with how canonical paths are generated -- it should probably be fixed in |
I thought about this and I don't think so because we should not be able to resolve https://godbolt.org/z/o6zz1hfKb The usual canonical path from within the crate is Should we provide |
We could have all lookups stop before they reach the parent of a |
It does look like we extend canonical paths to be global between crates and to exist for most (all? virtually all?) items, where in https://doc.rust-lang.org/reference/paths.html We should be fine, as long as we can still map our canonical paths to |
Rereading |
This is probably why it was working as intended with nr1, I'll give it a look tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those changes are fine. My gut feeling is we probably need to do something similar for exports? But I'm not sure. I think this is a fine solution though
Tbh I don't really like my own solution, initially I intended to modify the name resolution, add a name to the root node. Cons for this method are obvious as name resolution from crate name should be prevented. I'll take a few days to give this PR some thoughts. |
I think the simplest option here is the best one. This is a two-line change, whereas adding a name to the root would require changes in the forever stack and name resolution overall. Name resolution is mostly needed for the current crate - exports and imports are different and can be special cased. Resolving imports will always be a lot simpler than doing name resolution on the current crate, because we can control the representation of the exported data and it will all be flattened out. I think we should merge this, and not care about adding that little extra segment in front of the path. You can add a comment above the change to explain that we need to prepend IR names with the crate name for exporting reasons. I don't want to change name resolution and then have to do mental gymnastics to stop at the parent node and all that. name resolution is already extremely complex and I want it to stay as simple as possible |
Some pre nr2 were relying on function name, those name are prefixed with the crate's name.